package logger

import (
	"go.uber.org/zap"
)

type ZapLogger struct {
	l *zap.Logger
}

func NewZapLogger(l *zap.Logger) LoggerV1 {
	return &ZapLogger{l}
}

func (z *ZapLogger) With(fields ...Field) LoggerV1 {
	return &ZapLogger{
		l: z.l.With(z.toArgs(fields...)...),
	}
}

func (z *ZapLogger) Debug(msg string, fields ...Field) {
	//TODO implement me
	z.l.Debug(msg, z.toArgs(fields...)...)
}

func (z *ZapLogger) Info(msg string, fields ...Field) {
	//TODO implement me
	z.l.Info(msg, z.toArgs(fields...)...)
}

func (z *ZapLogger) Warn(msg string, fields ...Field) {
	//TODO implement me
	z.l.Warn(msg, z.toArgs(fields...)...)
}

func (z *ZapLogger) Error(msg string, fields ...Field) {
	//TODO implement me
	z.l.Error(msg, z.toArgs(fields...)...)
}

func (z *ZapLogger) toArgs(fields ...Field) []zap.Field {
	result := make([]zap.Field, 0, len(fields))
	for _, field := range fields {
		result = append(result, zap.Any(field.Name, field.Value))
	}
	return result
}
